<template>
  <div class="question-options">
    <!-- 单选题选项 - 横排展示 -->
    <div v-if="question.type === 'single'" class="options-container">
      <div 
        v-for="(text, key) in question.options" 
        :key="key"
        class="option-item">
        <div class="option-circle print-visible">{{ key }}</div>
        <div class="option-text print-visible" v-html="text"></div>
      </div>
    </div>

    <!-- 多选题选项 - 横排展示 -->
    <div v-if="question.type === 'multiple'" class="options-container">
      <div 
        v-for="option in question.options" 
        :key="option.value"
        class="option-item">
        <div class="option-square print-visible">{{ option.value }}</div>
        <div class="option-text print-visible">{{ option.text }}</div>
      </div>
    </div>

    <!-- 判断题选项 - 横排展示 -->
    <div v-if="question.type === 'truefalse'" class="options-container">
      <div class="option-item">
        <div class="option-circle print-visible">A</div>
        <div class="option-text print-visible">正确</div>
      </div>
      <div class="option-item">
        <div class="option-circle print-visible">B</div>
        <div class="option-text print-visible">错误</div>
      </div>
    </div>
  </div>
</template>

<script setup>
defineProps({
  question: {
    type: Object,
    required: true
  },
  mode: {
    type: String,
    default: 'paper'
  }
})
</script>

<style scoped>
/* 全局样式，确保打印时可见 */
@media print {
  .print-visible {
    display: flex !important;
    visibility: visible !important;
    color: black !important;
  }
  
  img {
    visibility: visible !important;
    display: inline-block !important;
  }
}



.question-options {
  margin-top: 0.5rem;
  page-break-inside: avoid;
}

.options-container {
  display: flex;
  flex-wrap: wrap;
  gap: 2rem;
  margin-top: 0.5rem;
}

.option-item {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  min-width: 80px;
}

.option-circle {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1px solid #000;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
  background-color: white;
}

.option-square {
  width: 24px;
  height: 24px;
  border-radius: 4px;
  border: 1px solid #000;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
  background-color: white;
}

.option-text {
  display: flex;
  align-items: center;
}

.option-text :deep(img) {
  max-width: 120px;
  max-height: 80px;
  object-fit: contain;
}

/* 打印样式优化 */
@media print {
  .question-options {
    margin-top: 0.5rem !important;
    visibility: visible !important;
    display: block !important;
  }
  
  .options-container {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 2rem !important;
    margin-top: 0.5rem !important;
    visibility: visible !important;
  }
  
  .option-item {
    display: inline-flex !important;
    align-items: center !important;
    gap: 0.5rem !important;
    margin-bottom: 0.5rem !important;
    visibility: visible !important;
  }
  
  .option-circle, .option-square {
    width: 24px !important;
    height: 24px !important;
    border: 1px solid #000 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    color: #000 !important;
    background-color: #fff !important;
    flex-shrink: 0 !important;
    visibility: visible !important;
  }
  
  .option-text {
    color: #000 !important;
    visibility: visible !important;
  }
  
  .option-text :deep(img) {
    visibility: visible !important;
    display: inline-block !important;
    max-width: 120px !important;
    max-height: 80px !important;
  }
}
</style>